﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace WP_GasTracker.Converters
{
    public class TextFormatConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Format(value, parameter);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Format(value, parameter);
        }

        static object Format(object value, object param)
        {
            return value == null
                ? value
                : string.Format(param.ToString(), value);
        }
    }
}
